package com.alliky.user.ui.activity;

import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;

import com.alliky.core.base.BaseActivity;
import com.alliky.core.widget.TitleBar;
import com.alliky.core.widget.rxdialog.RxDialog;
import com.alliky.user.R;
import com.alliky.user.R2;
import com.alliky.user.mvp.contract.PersonCenterContract;
import com.alliky.user.mvp.presenter.PersonCenterPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class PersonCenterBaseActivity extends BaseActivity<PersonCenterPresenter> implements PersonCenterContract.View {

    @BindView(R2.id.titleBar)
    TitleBar titleBar;
    @BindView(R2.id.arrow_header)
    ImageView arrowHeader;
    @BindView(R2.id.cl_header)
    ConstraintLayout clHeader;
    @BindView(R2.id.line_header)
    View lineHeader;
    @BindView(R2.id.icon_arrow_nickname)
    ImageView iconArrowNickname;
    @BindView(R2.id.cl_nickname)
    ConstraintLayout clNickname;
    @BindView(R2.id.line_nickname)
    View lineNickname;
    @BindView(R2.id.arrow_sex)
    ImageView arrowSex;
    @BindView(R2.id.cl_sex)
    ConstraintLayout clSex;

    @Override
    protected PersonCenterPresenter createPresenter() {
        return new PersonCenterPresenter(this);
    }

    @Override
    public Object setLayout() {
        return R.layout.activity_person_center;
    }

    @Override
    public void onInitView(@Nullable Bundle savedInstanceState) {
        titleBar.setLeftFinish(this);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick(R2.id.cl_header)
    public void onViewClicked(View view) {
        int id = view.getId();
        if (id == R.id.cl_header) {
            new RxDialog.Builder(getSupportFragmentManager())
                    .setLayoutRes(R.layout.dialog_common_bottom_select)
                    .setScreenWidthAspect(getContext(), 1.0f)
                    .setGravity(Gravity.BOTTOM)
                    .setDialogAnimationRes(R.style.animate_dialog)
                    .addOnClickListener(R.id.tv_open_camera, R.id.tv_open_album, R.id.tv_cancel)
                    .setOnViewClickListener((holder, v1, dialog) -> {
                        dialog.dismiss();
                    })
                    .create()
                    .show();
        }
    }
}